import pandas as pd
import os
# 读取指定列的数据
import requests
import pymysql
import run_request_service as ssr
import fnmatch

# 创建会话对象
session = requests.Session()
db = pymysql.connect(host='localhost', port=23306, user='root', password='Pr0dkcd_', db="kcdoc")
cursor = db.cursor()


def delete_user_image(userNo):
    delete = "DELETE FROM sys_att_t WHERE bus_type = 'esign' and bus_id = '{}'".format(userNo)
    cursor.execute(delete)
    db.commit()


def pullFile():
    # 指定目录路径
    directory = 'D:\\woker_file\\709\\电子签名\\pull'
    ssr.login('712017165048788d32c953896cc7ce4a')

    # List of files to ignore
    ignore_files = ['Thumbs.db', '.DS_Store']

    for root, dirs, files in os.walk(directory):
        # Filter out ignored files
        filtered_files = [file for file in files if file not in ignore_files]

        for filename in filtered_files:
            user_no = filename.split('.')[0]
            filepath = os.path.join(root, filename)  # 构建完整的文件路径
            if os.path.isfile(filepath):
                delete_user_image(user_no)
                ssr.updateFile(filepath, user_no)

if __name__ == '__main__':
    pullFile()
